package com.tangbuzhi.proxy;

/**
 * 代理模式
 */
public class Proxy {
    public interface Source {
        void source();
    }

    public static class RealSource implements Source {
        @Override
        public void source() {
            System.out.println("this is real source");
        }
    }

    public static class ProxySource implements Source {
        private Source source;

        public ProxySource(Source source) {
            this.source = source;
        }

        @Override
        public void source() {
            source.source();
        }
    }

    public static void main(String[] args) {
        RealSource realSource = new RealSource();
        ProxySource proxySource = new ProxySource(realSource);
        proxySource.source();//this is real source
    }
}
